package org.example.service.impl;


import org.example.dto.CreateOrderDto;
import org.example.entity.OrderEntity;
import org.example.mapper.OrderMapper;
import org.example.service.OrderAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigInteger;

@Service
public class   OrderAppServiceImpl implements OrderAppService {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * 创建订单
     * @param createOrderDto
     */
    public Long createOrder(CreateOrderDto createOrderDto){

        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderNo(createOrderDto.getOrderNo());
        orderEntity.setUserId(createOrderDto.getUserId());
        orderEntity.setStatus(createOrderDto.getStatus());
        orderEntity.setTotalPrice(createOrderDto.getTotalPrice());

        orderMapper.insert(orderEntity);

        return orderEntity.getId();
    }
}
